package com.shengyin.ec.model.entity;


import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="orders")
public class Orders extends BaseEntity {
	
	

	@ManyToOne(cascade={CascadeType.REFRESH})
	private ClusterCompany clusterCompany;
	
	
	
	@OneToMany(cascade=CascadeType.ALL,mappedBy="orders")
	private  List<OrderItem> orderItem=new ArrayList<OrderItem>();
	
	@ManyToOne(cascade={CascadeType.REFRESH})
	private Personal user;
	
	@ManyToOne
	private Delivery delivery;
	@ManyToOne
	private Payment payment;
	@ManyToOne
	private Receiver receiver;
	
	
	private String orderId="0";
	
	/*
	 * 订单状态
	 * 1.未付款
	 * 2.已付款
	 * 3.已付款未发货
	 * 4.已付款已发货
	 * 5.已完成
	 * */
	private String orderState;
	
	
	private String invoiceType;
	private float invoiceFee;
	
	private String note;
	
	private String inv_payee;
	
	private Date createDate;
	
	private Date lastDate;
	
	
	/**
	 * fort合并订单
	 * */
	
	private int shopCartCount;
	
	private double totalPrice;






	public List<OrderItem> getOrderItem() {
		return orderItem;
	}

	public void setOrderItem(List<OrderItem> orderItem) {
		this.orderItem = orderItem;
	}

	public Personal getUser() {
		return user;
	}

	public void setUser(Personal user) {
		this.user = user;
	}

	public Delivery getDelivery() {
		return delivery;
	}

	public void setDelivery(Delivery delivery) {
		this.delivery = delivery;
	}

	public Payment getPayment() {
		return payment;
	}

	public void setPayment(Payment payment) {
		this.payment = payment;
	}

	public String getOrderState() {
		return orderState;
	}

	public void setOrderState(String orderState) {
		this.orderState = orderState;
	}

	public String getInvoiceType() {
		return invoiceType;
	}

	public void setInvoiceType(String invoiceType) {
		this.invoiceType = invoiceType;
	}

	public float getInvoiceFee() {
		return invoiceFee;
	}

	public void setInvoiceFee(float invoiceFee) {
		this.invoiceFee = invoiceFee;
	}

	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	public int getShopCartCount() {
		return shopCartCount;
	}

	public void setShopCartCount(int shopCartCount) {
		this.shopCartCount = shopCartCount;
	}

	public double getTotalPrice() {
		return totalPrice;
	}

	public void setTotalPrice(double totalPrice) {
		this.totalPrice = totalPrice;
	}

	public Receiver getReceiver() {
		return receiver;
	}

	public void setReceiver(Receiver receiver) {
		this.receiver = receiver;
	}	
	
	public void mergeOrders(){
		
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public Date getLastDate() {
		return lastDate;
	}

	public void setLastDate(Date lastDate) {
		this.lastDate = lastDate;
	}

	public String getInv_payee() {
		return inv_payee;
	}

	public void setInv_payee(String inv_payee) {
		this.inv_payee = inv_payee;
	}

	
	
	public void addOrderItem(OrderItem orderItem){
		orderItem.setOrders(this);
		this.orderItem.add(orderItem);
	}

	public ClusterCompany getClusterCompany() {
		return clusterCompany;
	}

	public void setClusterCompany(ClusterCompany clusterCompany) {
		this.clusterCompany = clusterCompany;
	}

	public String getOrderId() {
		return orderId;
	}

	public void setOrderId(String orderId) {
		
		this.orderId = orderId;
	}
	
	
}
